package com.xianlai.ad.ad_common.splash

import android.app.Activity
import android.content.Context
import android.view.ViewGroup

abstract class ThirdSplashAd(protected val context: Context,
                             protected val appId: String,
                             protected val appKey: String,
                             val placementId: String) {
    abstract fun init()
    abstract fun isReady(): Boolean
    abstract fun isShowing(): Boolean
    abstract fun setThirdSplashAdStatusListener(listener: ThirdSplashAdStatusListener)

    /**
     * 加载广告
     * @return 加载成功、失败
     */
    abstract suspend fun load(): Boolean

    /**
     * 显示广告
     * @return 广告显示+消失 、广告未显示
     */
    abstract suspend fun show(activity: Activity, viewGroup: ViewGroup, skipView: ISplashSkipView?): Boolean

    interface ThirdSplashAdStatusListener {
        fun onAdLoaded(isTimeout: Boolean, detailMap: Map<String, Any>)
        fun onAdLoadTimeout()
        fun onNoAdError(code: String, desc: String)
        fun onAdShow(detailMap: Map<String, Any>)
        fun onAdClick()
        fun onAdDismiss()
    }
}